% function to convert 
% dd mm yy format to Julian date
% original Java script at http://skye.as.arizona.edu/~turnbull/JD-calendar.html

% latest date 27.11.2002



function[JD] = dmy2jd(DD,MM,YY),

      GGG = 1;
      if (YY <= 1585),
	 GGG = 0;
	end;

      JD = -1 * floor(7 * (floor((MM + 9) / 12) + YY) / 4);
      S = 1;
      if ((MM - 9)<0),
	 S=-1;
	end;
      A = abs(MM - 9);
      J1 = floor(YY + S * floor(A / 7));
      J1 = -1 * floor((floor(J1 / 100) + 1) * 3 / 4);
      JD = JD + floor(275 * MM / 9) + DD + (GGG * J1);
      JD = JD + 1721027 + 2 * GGG + 367 * YY;
